﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QLBH.Base;
using QLBH.DataModel;
using QLBH.ModelInterface;

namespace QLBH.FeatureModel
{
    public class QLNhanVienModel:IQLNhanVienModel
    {
        public Guid NVID { set; get; }
        public String MANV { set; get; }
        public String TENNV { set; get; }
        public DateTime NGAYSINH { set; get; }
        public String QUEQUAN { set; get; }
        public String DIACHI { set; get; }
        public String SDT { set; get; }
        public String DIDONG { set; get; }
        public String CMTND { set; get; }
        public String EMAIL { set; get; }
        public Decimal LUONGCB { set; get; }
        public String GHICHU { set; get; }
        public DateTime NGAYTAO { set; get; }
        public String USERNAME { set; get; }

        /// <summary>
        /// initialize model from nhanvien entity
        /// </summary>
        /// <param name="entity"></param>
        public void InitFromEntity(NHANVIEN entity)
        {
            NVID = entity.NVID;
            MANV = entity.NVCODE;
            TENNV = entity.TENNV;
            NGAYSINH = (DateTime)entity.NGAYSINH;
            QUEQUAN = entity.QUEQUAN;
            DIACHI = entity.DIACHI;
            SDT = entity.SDT;
            DIDONG = entity.DIDONG;
            CMTND = entity.CMTND;
            EMAIL = entity.EMAIL;
            LUONGCB = (Decimal)entity.LUONGCOBAN;
            GHICHU = entity.GHICHU;
            NGAYTAO = (DateTime)entity.NGAYTAO;

            if(entity.ACOUNT!=null)
            {
                USERNAME = entity.ACOUNT.UserName;
            }
            
        }

        /// <summary>
        /// Create NHANVIEN entity from model
        /// </summary>
        /// <returns></returns>
        public NHANVIEN ToEntity()
        {
            NHANVIEN entity = new NHANVIEN();
            entity.NVID=NVID;
            entity.NVCODE = MANV;
            entity.TENNV = TENNV;
            entity.NGAYSINH = NGAYSINH;
            entity.QUEQUAN = QUEQUAN;
            entity.DIACHI = DIACHI;
            entity.SDT = SDT;
            entity.DIDONG = SDT;
            entity.CMTND = CMTND;
            entity.EMAIL = EMAIL;
            entity.LUONGCOBAN = LUONGCB;
            entity.GHICHU = GHICHU;
            entity.NGAYTAO = NGAYTAO;           

            return entity;
        }
    }
}
